//
//  RW_SetupViewModel.m
//  Yule
//
//  Created by 王亮 on 2021/1/22.
//  Copyright © 2021 Yule.dating. All rights reserved.
//

#import "RW_SetupViewModel.h"
#import "RW_SetupModel.h"
#import "RW_SetupItemCollectionViewCell.h"

@implementation RW_SetupViewModel

#pragma mark -- 数据获取
/** 生成显示视图 */
-(NSArray<WLBaseCollectionViewLayerSection *> *)getCollectionSection{
    NSMutableArray *array = [NSMutableArray array];
    
    NSArray *showArray = @[
        @(Setup_Cell_Type_Clean),
        @(Setup_Cell_Type_Privacy),
        @(Setup_Cell_Type_Protocol),
        @(Setup_Cell_Type_Copyright),
        @(Setup_Cell_Type_About),
    ];
    WLBaseCollectionViewLayerSection *section = [[WLBaseCollectionViewLayerSection alloc]init];
    section.insetForSection = UIEdgeInsetsMake(0, 0, 0, 0);
    section.horizontalSection = 0;
    section.horizontalCount = 1;
    section.horizontalMaxWidth = Main_Screen_Width;
    section.verticalSection = 1;
    
    CGSize itemSize = [section getCellSizeHeight:40];
    for (NSNumber *num in showArray) {
        Setup_Cell_Type t = (Setup_Cell_Type)[num intValue];
        RW_SetupModel *model = [[RW_SetupModel alloc]init];
        model.type = t;
        [section.item addObject:[RW_SetupItemCollectionViewCell getRow:model
                                                              cellSize:itemSize]];
    }
    [array addObject:section];
    
    if ([UserModel_WL isLogin]){
        WLBaseCollectionViewLayerSection *loginOutSection = [[WLBaseCollectionViewLayerSection alloc]init];
        loginOutSection.item = [NSMutableArray array];
        loginOutSection.insetForSection = UIEdgeInsetsMake(15, 15, 0, 15);
        loginOutSection.horizontalSection = 0;
        loginOutSection.horizontalCount = 1;
        loginOutSection.horizontalMaxWidth = Main_Screen_Width;

        loginOutSection.verticalSection = 0;
        
        RW_SetupModel *model = [[RW_SetupModel alloc]init];
        model.type = Setup_Cell_Type_Login_Out;
        
        [loginOutSection.item addObject:[RW_SetupItemCollectionViewCell getRow:model
                                                                      cellSize:[loginOutSection getCellSizeHeight:40]]];
        [array addObject:loginOutSection];
    }
    return array;
}




-(NSString *)nav_title{
    if (!_nav_title){
        _nav_title = @"设置";
    }
    return _nav_title;
}
@end
